<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    书名: <input type="text" class="bookname"><br>
    作者: <input type="text" class="author"><br>
    出版: <input type="text" class="publisher"><br>
    <button>添加</button>
</body>
</html>
<script src="../BigNews/admin/libs/jquery-1.12.4.min.js"></script>
<script>
$(function(){
    $('button').on('click',function () {  
    let bookname=$('.bookname').val().trim()
    let author=$('.author').val().trim()
    let publisher=$('.publisher').val().trim()

    $.ajax({
        url:'http://www.liulongbin.top:3006/api/addbook',
        data:{
            // 使用es6中的对象解构语法 即可减写  但是规定对象成员要与赋值语句的命名一致
            bookname,
            author,
            publisher
        },
        type:'post',
        success:function(backData){
            console.log(backData);
            
        }
    })
})
})




</script>